package com.relytosoft.mizar.media.analyze.services.service.face;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.relytosoft.dubhe.common.core.base.page.PageQuery;
import com.relytosoft.mizar.media.analyze.api.entity.face.AyFaceTaskSon;
import com.relytosoft.mizar.media.analyze.api.pojo.dto.AyFaceTaskSonDto;
import com.relytosoft.mizar.media.analyze.api.pojo.query.AyFaceTaskSonQuery;
import com.relytosoft.mizar.media.analyze.api.pojo.vo.AyBatchVo;
import com.relytosoft.mizar.media.analyze.api.pojo.vo.AyFaceTaskSonVo;

import java.util.List;

/**
 * AyFaceTaskSonService
 *
 * @Author SunLi
 * @Date: 2022/6/1 18:32
 * @Version 1.0
 */
public interface AyFaceTaskSonService  extends IService<AyFaceTaskSon> {
    /**
     * 分页查询
     * @param pageQuery
     * @param ayFaceTaskSonQuery
     * @return
     */
    IPage<AyFaceTaskSonVo> selectAyFaceTaskSonPageList(PageQuery pageQuery, AyFaceTaskSonQuery ayFaceTaskSonQuery);

    /**
     * 添加子任务/添加通道
     *
     * @param ayFaceTaskSonDto
     * @param taskName
     */
    AyBatchVo insertAyFaceTaskSon(AyFaceTaskSonDto ayFaceTaskSonDto, String taskName);

    /**
     * 删除子任务
     * @param ids
     * @return
     */
    boolean deleteAyFaceTaskSon(List<Integer> ids);

    /**
     * 获取可启动的子任务
     * @param ids
     * @param structureTaskId
     * @return
     */
    List<AyFaceTaskSon> selectCanStartTaskSonList(List<Integer> ids,Integer structureTaskId);

    /**
     * 获取可停止的子任务
     * @param ids
     * @param structureTaskId
     * @return
     */
    List<AyFaceTaskSon> selectCanStopTaskSonList(List<Integer> ids,Integer structureTaskId);
    /**
     * 删除并启动结构化子任务
     */
    boolean deleteAndStartTaskSonList(List<AyFaceTaskSon> deleteSonList,List<AyFaceTaskSon> insertSonList,Integer structureTaskId);

    /**
     * 启动结构化子任务
     */
    boolean startTaskSonList(List<AyFaceTaskSon> startSonList,Integer structureTaskId);
    /**
     * 停止结构化子任务
     */
    boolean stopTaskSonList(List<AyFaceTaskSon> stopSonList,Integer structureTaskId);

    /**
     * 根据主任务删除子任务
     * @param ids
     * @return
     */
    boolean deleteByTask(List<Integer> ids);

    /**
     * 发送创建分析任务消息
     * @param ayFaceTaskSon
     */
    void sendInsertTaskMsg(AyFaceTaskSon ayFaceTaskSon);

    /**
     * 发送删除分析任务消息
     * @param taskId
     */
    void sendDeleteTaskMsg(String taskId);

    void buildDeleteAndStartTaskSon(List<AyFaceTaskSon> taskSonList,List<AyFaceTaskSon> deleteTaskSons,List<AyFaceTaskSon> insertTaskSons);

    void buildStartTaskSon(List<AyFaceTaskSon> taskSonList,List<AyFaceTaskSon> startTaskSons);

    void buildStopTaskSon(List<AyFaceTaskSon> taskSonList,List<AyFaceTaskSon> stopTaskSons);

    /**
     * 根据第三方任务ID获取任务信息
     * @param taskId
     * @return
     */
    AyFaceTaskSon getByTaskId(String taskId);

    /**
     * 查询指定任务ID集合中是否有异常任务
     * @param ids
     * @return
     */
    List<AyFaceTaskSon> selectUnusualTaskSons(List<Integer> ids);
}
